#include "projectdata.h"

ProJectData::ProJectData()
{

}
QByteArray ProJectData::Get_Download_REIGSTER_Res(bool Status,QString uid)
{
    QJsonObject pageObject;
    pageObject.insert("Type","REIGSTER_RES");
    pageObject.insert("Status",Status);
    pageObject.insert("uid",uid);
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Download_LOGIN_Res(QString Res,QString uid,QString name,QString pwd)
{
    QJsonObject pageObject;
    pageObject.insert("Type","LOGIN_RES");
    pageObject.insert("uid",uid);
    pageObject.insert("name",name);
    pageObject.insert("passwd",pwd);
    pageObject.insert("Status",Res);


    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Download_MSG_SYNC(QString Groupid,bool isgroup, QVector<QString>Msg)
{

    QJsonObject pageObject;
    pageObject.insert("Type","MSG_SYNC");
    pageObject.insert("GID",Groupid);
    pageObject.insert("MSG_NUM",Msg.size());
    pageObject.insert("is_group",isgroup);
    for(int i = 0;i<Msg.size();i++)
    {
        pageObject.insert("MSG"+QString::number(i),Msg[i]);
    }
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Download_MSG_UPDATE(bool isgroup,QString Groupid, QVector<QString>Msg)
{
    QJsonObject pageObject;
    pageObject.insert("Type","MSG_UPDATE");
    pageObject.insert("GID",Groupid);
    pageObject.insert("MSG_NUM",Msg.size());
    pageObject.insert("is_group",isgroup);
    for(int i = 0;i<Msg.size();i++)
    {
        pageObject.insert("MSG"+QString::number(i),Msg[i]);
    }
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}

QByteArray ProJectData::Get_Download_LIST_SYNC(QVector<QString>List)
{
    QJsonObject pageObject;
    pageObject.insert("Type","LIST_SYNC");
    pageObject.insert("LIST_NUM",List.size());
    for(int i = 0;i<List.size();i++)
    {
        pageObject.insert("LIST"+QString::number(i),List[i]);
    }
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Download_POST_SYNC(QVector<QString> PostList)
{
     QJsonObject pageObject;
     pageObject.insert("Type","POST_SYNC");

     pageObject.insert("LIST_NUM",PostList.size());
     for(int i = 0;i<PostList.size();i++)
     {
         pageObject.insert("LIST"+QString::number(i),PostList[i]);
     }

     QJsonDocument document;
     document.setObject(pageObject);
     QByteArray byteArray = document.toJson(QJsonDocument::Compact);
     return (byteArray);

}
QByteArray ProJectData::Get_Download_CreateGroup_Res(bool res)
{
    QJsonObject pageObject;
    pageObject.insert("Type","CREATE_GROUP");

    pageObject.insert("RES",res);

    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_CHECK_NUM(QString Check_num)
{
    QJsonObject pageObject;
    pageObject.insert("Type","CHECK");
    pageObject.insert("CHECK_NUM",Check_num);
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_CHECK_POST_uid(QString uid)
{
    QJsonObject pageObject;
    pageObject.insert("Type","CHECK");
    pageObject.insert("uid",uid);
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_CHECK_POST_phone(QString PhoneNum)
{
    QJsonObject pageObject;
    pageObject.insert("Type","CHECK");
    pageObject.insert("phone",PhoneNum);
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_PULL_FRIEND(QString uid,QString GID)
{
    QJsonObject pageObject;
    pageObject.insert("Type","PULL_FRIEND");
    pageObject.insert("uid",uid);
    pageObject.insert("GID",GID);
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_APPLAY_GROUP(QString uid,QString GID)
{
    QJsonObject pageObject;
    pageObject.insert("Type","APPLAY_GROUP");
    pageObject.insert("uid",uid);
    pageObject.insert("GID",GID);
    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_LOGIN_POST(QString uid,QString pwd,QString IP,QString CheckNum)//上行登录请求
{
    QJsonObject pageObject;
    pageObject.insert("Type","LOGIN");
    pageObject.insert("uid",uid);
    pageObject.insert("passwd",pwd);
    pageObject.insert("CHECK_NUM",CheckNum);
    pageObject.insert("IP",IP);

    QJsonDocument document;
    document.setObject(pageObject);
    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);

}

QByteArray ProJectData::Get_Upload_ADDFRIEND(QString uid, QString Gid,bool Add)
{
    QJsonObject pageObject;
    pageObject.insert("Type","ADD_Status");
    pageObject.insert("uid",uid);
    pageObject.insert("GID",Gid);
    pageObject.insert("Status",Add);
    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}

QByteArray ProJectData::Get_Upload_CreateGroup(QString uid_me,QVector<QString> UID,bool isgroup)
{
    QJsonObject pageObject;
    pageObject.insert("Type","CREATE_GROUP");
    pageObject.insert("isgroup",isgroup);
    pageObject.insert("uid",uid_me);
    pageObject.insert("list_num",UID.size());
    for(int i =0;i<UID.size();i++)
    {
        pageObject.insert("uid_other"+QString(i),UID[i]);
    }


    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_REGISTER_POST(QString name,QString pwd,QString check,QString phone,QString IP) //上行注册请求
{
    QJsonObject pageObject;
    pageObject.insert("Type","RIGSTER");
    pageObject.insert("name",name);
    pageObject.insert("passwd",pwd);
    pageObject.insert("IP",IP);
    pageObject.insert("PhoneNumber",phone);
    pageObject.insert("CHECK_NUM",check);

    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_LIST_SYNC(QString uid)
{
    QJsonObject pageObject;
    pageObject.insert("Type","LIST_SYNC");
    pageObject.insert("uid",uid);
    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_MSG_SYNC(QString GID)
{
    QJsonObject pageObject;
    pageObject.insert("Type","MSG_SYNC");
    pageObject.insert("GID",GID);

    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Upload_POST_SYNC(QString uid)
{
    QJsonObject pageObject;
    pageObject.insert("Type","POST_SYNC");
    pageObject.insert("uid",uid);
    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_MSG(QString seneruid,QString Groupid,QString MSG,QString Time)
{
    QJsonObject pageObject;
    pageObject.insert("Type","MSG");

    pageObject.insert("Sender",seneruid);
    pageObject.insert("Reciver",Groupid);
    pageObject.insert("MSG",MSG);
    pageObject.insert("TimeStamp",Time);

    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_Usr(QString uid,QString name)
{
    QJsonObject pageObject;
    pageObject.insert("Type","USR_INFO");

    pageObject.insert("uid",uid);
    pageObject.insert("name",name);

    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);
}
QByteArray ProJectData::Get_LIST(QString Type ,QString uid_group,QString Gid,bool is_group,QVector<QString> UsrInfo)
{
    QJsonArray  UsrObject;
    for(int i = 0;i<UsrInfo.size();i++)
        UsrObject.append(UsrInfo[i]);

    QJsonObject pageObject;
    pageObject.insert("Type",Type);
    pageObject.insert("GID",Gid);
    pageObject.insert("uid_adder",uid_group);

    pageObject.insert("isgroup",is_group);
    pageObject.insert("USR_LIST",UsrObject);

    QJsonDocument document;
    document.setObject(pageObject);

    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
    return (byteArray);

}
